<?php
/**
* @package Admin Tool Kit - Organize Lang
* @id $Id: organize_lang.php 84 2008-08-23 17:03:30Z exreaction@gmail.com $
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

if (!defined('IN_PHPBB'))
{
	exit;
}

class organize_lang
{
	var $auto_include = array(
		'organize_lang_functions' => true,
	);

	/**
	* Tool Info
	*
	* @return Returns an array with the info about this tool.
	*/
	function info()
	{
		global $user;

		return array(
			'NAME'			=> $user->lang['ORGANIZE_LANG'],
			'NAME_EXPLAIN'	=> $user->lang['ORGANIZE_LANG_EXPLAIN'],

			'CATEGORY'		=> $user->lang['DEV_TOOLS'],
		);
	}

	/**
	* Display Options
	*
	* Output the options available
	*/
	function display_options()
	{
		return array(
			'title'	=> 'ORGANIZE_LANG',
			'vars'	=> array(
				'legend1'			=> 'ORGANIZE_LANG',
				'file'				=> array('lang' => 'ORGANIZE_LANG_FILE', 'type' => 'text:40:255', 'explain' => true),
			)
		);
	}

	/**
	* Run Tool
	*
	* Does the actual stuff we want the tool to do after submission
	*/
	function run_tool(&$error)
	{
		global $phpbb_root_path, $phpEx;

        if (!check_form_key('organize_lang'))
		{
			$error[] = 'FORM_INVALID';
			return;
		}

		$file = request_var('file', '');
		if (!$file || (!file_exists($phpbb_root_path . 'language/' . $file) && !file_exists($phpbb_root_path . 'language/' . $file . '.' . $phpEx)))
		{
			$error[] = 'NO_FILE';
			return;
		}

		organize_lang($file);

		trigger_error('ORGANIZE_LANG_SUCCESS');
	}
}
?>